module.exports = class extends think.Model {
  /// 获取平台收支概括
  async info () {
    const db = think.mongoose('mongo/deal')
    /// 获取收支的订单
    let order = await db.find({
      type: {
        $in: ['upgrade', 'charge', 'cash']
      },
      status: 1
    })
    let data = {
      income: 0, expend: 0
    }
    order.forEach(item => {
      if (item.type === 'cash') {
        data.expend += item.money
      } else {
        data.income += item.money
      }
    })
    return data
  }
};
